#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
/* *
Definition for singly - linked list.
* struct ListNode {
    *int val;
    *struct ListNode* next;
    *
};
*/
struct ListNode {
    int val;
    struct ListNode* next;
};
typedef struct ListNode ListNode;
struct ListNode* removeElements(struct ListNode* head, int val) 
{
    if (head == NULL)
        return head;
    while (head->val == val)
        head = head->next;
    ListNode* prev = head;
    ListNode* ago = NULL;
    while (prev != NULL)
    {
        
        if (prev->val == val)
        {
            ListNode* del = prev;
            ago->next = prev->next;
            prev = prev->next;
            free(del);
            del == NULL;
        }
        ago = prev;
    }
    return head;
}